<?php

function getSN($prefix)
{
    mt_srand((double) microtime() * 1000000);
    return $prefix . date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
}

function getDemandStatus()
{
    return json_encode(C('DEMAND_CONFIG.STATUS'));
}

function getDemandType()
{
    return json_encode(C('DEMAND_CONFIG.TYPE'));
}

function getDemandSource()
{
    return json_encode(C('DEMAND_CONFIG.SOURCE'));
}

function makeInviteCode()
{
    $code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $rand = $code[rand(0, 25)] . strtoupper(dechex(date('m'))) . date('d') . substr(time(), - 5) . substr(microtime(), 2, 5) . sprintf('%02d', rand(0, 99));
    for ($a = md5($rand, true), $s = '0123456789ABCDEFGHIJKLMNOPQRSTUV', $d = '', $f = 0; $f < 8; $g = ord($a[$f]), $d .= $s[($g ^ ord($a[$f + 8])) - $g & 0x1F], $f ++);
    return $d;
}